package com.retirement.children.controller;

import com.retirement.children.domain.OldChildren;
import com.retirement.children.dto.OldChildrenDto;
import com.retirement.children.service.IOldChildrenService;
import com.retirement.children.vo.OldChildrenVo;
import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijy
 * @since 2023-12-22
 */
@Api(value = "子女信息管理", tags = "子女信息管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/children")
public class OldChildrenController extends BaseController {

    private final IOldChildrenService iOldChildrenService;


    @GetMapping("/page")
    @ApiOperation(value = "分页查询基础信息")
    public TableDataInfo listOldInformation(OldChildrenDto dto){
        startPage();
        return getDataTable(iOldChildrenService.getList(dto));
    }

    @PostMapping
    @ApiOperation(value = "新增子女信息")
    public AjaxResult addChildren(@RequestBody OldChildren dto){
        return AjaxResult.success(iOldChildrenService.addChildren(dto));
    }

    @PutMapping
    @ApiOperation(value = "修改子女信息")
    public AjaxResult updateChildren(@RequestBody OldChildren dto){
        return AjaxResult.success(iOldChildrenService.updateChildren(dto));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除子女信息")
    public AjaxResult deleteChildren(@PathVariable("id") String id){
        return AjaxResult.success(iOldChildrenService.removeById(id));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取详情信息")
    public OldChildrenVo getDetail(@PathVariable("id") String id){
        return iOldChildrenService.getDetail(id);
    }

}
